﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TexasHoldem.RankedHands
{
    public class PairHand: RankedHand
    {
        private PairHand(Hand hand) : base(hand) { }
        public static PairHand TryCreateFrom(Hand hand)
        {
            if (hand.Cards.GroupBy(c => c.Face).Any(g => g.Count() >= 2))
                return new PairHand(hand);
            return null;
        }

        public override string RankName
        {
            get { return "One Pair"; }
        }

        protected override ushort RankingStrength
        {
            get { return 1; }
        }

        protected override IEnumerable<Card> FindDefiningCards()
        {
            return Cards.GroupBy(c => c.Face).OrderByDescending(g => g.Count()).First();
        }
    }
}
